﻿using System;
using StockModel;
using Utils.Extensions;

namespace StockEngine.Extensions
{
	internal static class MarketExtension
	{
		public static DateTime FindPreviousWorkingDay(this ExchangeMarket market, DateTime startDate)
		{
			DateTime result = startDate;

			do
			{
				result = result.GetPreviousNonWeekendDay();
			} while (market.Holidays.Contains(result));

			return result;
		}
	}
}
